//
//  WKMyWalletHeaderView.m
//  ourToken
//
//  Created by wakeup on 2018/6/1.
//  Copyright © 2018年 ourtoken. All rights reserved.
//

#import "WKMyWalletHeaderView.h"

@implementation WKMyWalletHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.walletImage];
        [self addSubview:self.label1];
        [self addSubview:self.label2];
        [self addSubview:self.lineView];
        [self addSubview:self.label3];
        [self addSubview:self.text4];
    }
    return self;
}

- (UIImageView *)walletImage {
    if (_walletImage == nil) {
        _walletImage = [[UIImageView alloc] initWithFrame:CGRectMake((AppManager.width-40)/2, 25, 40, 40)];
        _walletImage.image = [UIImage imageNamed:@"my_about"];
    }
    return _walletImage;
}

- (UILabel *)label1 {
    if (_label1 == nil) {
        _label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.walletImage.frame), AppManager.width, 25)];
        _label1.textAlignment = NSTextAlignmentCenter;
        _label1.text = @"10 BTC";
        _label1.font = AppManager.tableTextFont;
    }
    return _label1;
}

- (UILabel *)label2 {
    if (_label2 == nil) {
        _label2 = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.label1.frame), AppManager.width, 25)];
        _label2.textAlignment = NSTextAlignmentCenter;
        _label2.text = @"经历过撒估价师";
        _label2.font = AppManager.tableDetailFont;
        _label2.textColor = AppManager.tableDetailColor;
    }
    return _label2;
}

- (UILabel *)label3 {
    if (_label3 == nil) {
        _label3 = [[UILabel alloc] initWithFrame:CGRectMake(15, self.text4.frame.origin.y-25, AppManager.width-15, 25)];
        _label3.textAlignment = NSTextAlignmentLeft;
        _label3.text = @"钱包名称";
        _label3.font = AppManager.tableTextFont;
    }
    return _label3;
}

- (UITextField *)text4 {
    if (_text4 == nil) {
        _text4 = [[UITextField alloc] initWithFrame:CGRectMake(15, self.frame.size.height-35, AppManager.width-15, 25)];
        _text4.textAlignment = NSTextAlignmentLeft;
        _text4.text = @"10 BTC";
        _text4.font = AppManager.tableTextFont;
        _text4.textColor = AppManager.tableDetailColor;
    }
    return _text4;
}

- (UIView *)lineView {
    if (_lineView == nil) {
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(15, self.frame.size.height-0.5, AppManager.width-15, 0.5)];
        _lineView.backgroundColor = AppManager.tableDetailColor;
    }
    return _lineView;
}

- (void)setWalletModel:(WKWalletModel *)walletModel {
    _walletModel = walletModel;

    self.label1.text = [NSString stringWithFormat:@"%@ %@",walletModel.balanceCoin,walletModel.coinType];
    self.label2.text = walletModel.address;
    self.text4.text = walletModel.name;
    
    if ([walletModel.coinType isEqualToString:@"BTC"]) {
        self.walletImage.image = [UIImage imageNamed:@"b"];
    }
    else if ([walletModel.coinType isEqualToString:@"ETH"]) {
        self.walletImage.image = [UIImage imageNamed:@"e"];
    }
}

//收键盘
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.text4 resignFirstResponder];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
